/*
 * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.baomidou.mybatisplus.advance.query;


import com.baomidou.mybatisplus.advance.query.enums.DirectionEnum;
import com.baomidou.mybatisplus.advance.query.enums.OperatorEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * 过滤条件实体
 * @author wanglei
 * @since 2022-03-14
 */
@Data
@Builder
@ApiModel(
        description = "查询条件"
)
@Schema(title = "查询条件")
@AllArgsConstructor
public class QueryField implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(
            name = "property",
            notes = "实体类属性"
    )
    @Schema(name = "property",title = "实体类属性")
    private String property;
    @ApiModelProperty(
            name = "operator",
            notes = "比较符",
            example = "="
    )
    @Schema(name = "operator",title = "比较符号",example = "= > >= < <= != like like_r like_l not_like is_null not_null in")
    private String operator;
    @ApiModelProperty(
            name = "value",
            notes = "比较值"
    )
    @Schema(name = "value",title = "比较值",example = "= > >= < <= != like like_r like_l not_like is_null not_null in")
    private Object value;
    @ApiModelProperty(
            name = "relation",
            notes = "同一个分组内的多个条件之间的组合关系，默认为and",
            example = "AND"
    )
    @Schema(name = "relation",title = "多个条件之间的关联关系",example = "AND/OR")
    private String relation;
    @ApiModelProperty(
            name = "group",
            notes = "查询条件分组，默认分组为main，多个分组默认按照and的关系组合在一起",
            example = "main"
    )
    @Schema(name = "group",title = "查询条件分组，默认分组为main，多个分组默认按照relation的关系组合在一起",example = "main")
    private String group;

    public QueryField() {
        this.operator = OperatorEnum.EQ.getOperator();
        this.relation = DirectionEnum.DESC.name();
        this.group = "main";
    }

}
